package reduce.fz.com.reduce.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.volley.toolbox.ImageLoader;

import java.util.List;

import de.greenrobot.event.EventBus;
import reduce.fz.com.reduce.R;
import reduce.fz.com.reduce.bean.FindBanner;
import reduce.fz.com.reduce.custom.NetImage;
import reduce.fz.com.reduce.event.BaseEvent;
import reduce.fz.com.reduce.event.EventCode;

/**
 * Created by qingshengzheng on 15/7/5.
 */
public class FindBannerPagerAdapter extends PagerAdapter {
    private List<FindBanner> bannerList;
    private Context context;
    private LayoutInflater mLayoutInflater;
    private ImageLoader mImageLoader = null;

    public FindBannerPagerAdapter(Context context, List<FindBanner> bannerList) {
        this.context = context;
        this.bannerList = bannerList;
        this.mLayoutInflater = LayoutInflater.from(context);

    }

    @Override
    public int getCount() {
        return bannerList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == (View) object;
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View v = mLayoutInflater.inflate(R.layout.view_netimage_item, container, false);
        NetImage image = (NetImage) v.findViewById(R.id.cu_net_image);
        image.setImageUrl(bannerList.get(position).getImgUrl(), mImageLoader);
        image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
        return v;
    }


}
